﻿@model VideoCache.Server.MVCWeb.Areas.Admin.Models.AlbumSiteModel
@{
    ViewBag.Title = "剧集列表";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
@section css
{
<!-- jQuery EasyUI css -->
<link href="@Url.Content("~/content/easyui/default/easyui.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/content/easyui/icon.css")" rel="stylesheet" type="text/css" />
}

@section script
{
    <!-- jQuery EasyUI JS -->
    <script src="@Url.Content("~/Scripts/jquery.easyui.min.js")" type="text/javascript"></script>
    <script type="text/javascript">
    function searchEpisodes(albumId)
    {
        $.ajax({
            url : '@Url.Action("UpdateEpisodes", "Episode", new { area = "Admin" })',
            data : { "albumId" : albumId },
            type : "POST",
            dataType : "json",
            success: function () { alert('完成'); },
            error: function() { alert('错误'); }
        });
    }

    function deleteEpisode(obj)
    {
        var siteId = $(obj).attr("siteId");
        var episodeId = $(obj).attr("episodeId");

        $.post("@Url.Action("Delete", "Episode", new { area = "Admin" })" , { "id" : episodeId }, function(){
            $("#site_" + siteId).datagrid("reload");
        });

        return false;
    }
    </script>
}
<div class="panel" title="视频信息">
    <table width="100%">
        <tr>
            <td width="80" style="text-align: right">视频名称：</td>
            <td colspan="5">@Model.Title</td>
        </tr>
        <tr>
            <td width="80" style="text-align: right">类别：</td>
            <td width="100">@Html.GetDictionary(Model.TypeId)</td>
            <td width="80" style="text-align: right">上映地区：</td>
            <td width="100">@Html.GetDictionary(Model.AreaId)</td>
            <td width="80" style="text-align: right">上映日期：</td>
            <td>@Model.PubYear</td>
        </tr>
        <tr>
            <td width="80" style="text-align: right">导演：</td>
            <td width="100">@Model.Director</td>
            <td width="80" style="text-align: right">主演：</td>
            <td colspan="3">@Model.Actor</td>
        </tr>
    </table>
</div>
<div class="panel">
    <a href="@Url.Action("Create", "Episode", new { area = "Admin", albumId=Model.Id })" class="lbtn">新建</a>
    <a href="javascript:searchEpisodes(@Model.Id)" class="lbtn">更新剧集</a>
    <a href="@Url.Action("ClearEpisode", new { albumId = Model.Id })" onclick="return confirm('确定要清空剧集吗？')" class="lbtn">清空剧集</a>
    <a href="@Url.Action("FindAllToken", new { albumId = Model.Id })" class="lbtn">检测所有标记</a>
</div>

<div class="easyui-tabs">
    @foreach (var item in Model.Sites)
    {
    <div title="@item.DisplayName (@(item.Episodes.Count))" id="tabs-@(item.Id)">
        <div style="padding: 5px; border: 1px solid #ddd">
            <a href="@Url.Action("Create", new { area = "Admin", albumId=Model.Id, siteId=item.Id })" class="lbtn">新建</a>
            <a href="@Url.Action("Delete")" class="selectDelete lbtn" group="site@(item.Id)">删除</a>
            @if (item.AllowDownload > 0)
            {
                <a href="@Url.Action("SetDownload")" class="selectDelete lbtn" group="site@(item.Id)">设为下载点</a>
            }
            <a href="@Url.Action("FindToken")" class="selectDelete lbtn" group="site@(item.Id)">检测标记</a>
        </div>
        <table class="ten-table" width="100%">
        <thead>
            <tr>
                <th style="width:10px;text-align:center"><input type="checkbox" group="site@(item.Id)" class="selectAll" /></th>
                <th style="width:50px;text-align:center">剧集</th>
                <th style="width:220px">名称</th>
                <th style="width:260px">标记</th>
                <th>网址</th>
                <th style="width:80px;text-align:center">允许下载</th>
                <th style="width:160px;text-align:center">更新时间</th>
                <th style="width:120px;text-align:center"></th>
            </tr>
        </thead>
        <tbody>
        @foreach (var episode in item.Episodes)
        {
            <tr>
                <td style="text-align:center"><input type="checkbox" group="site@(item.Id)" value="@episode.Id" /></td>
                <td style="width:50px;text-align:center">@episode.EpisodeIndex</td>
                <td style="width:120px">@Html.ShowText(episode.Name,25)</td>
                <td style="width:160px">@episode.Token</td>
                <td>@episode.Url</td>
                <td style="width:80px;text-align:center">
                    @if(episode.AllowDownload > 0){ <span>是</span> }
                    else{ <span>否</span> }
                </td>
                <td style="width:160px;text-align:center">@episode.ModifyTime</td>
                <td style="width:160px;text-align:center">
                    @if (episode.AllowDownload == 0)
                    {
                        <a href="@Url.Action("download", new { id = episode.Id, allow = true })">允许下载</a>
                    }
                    else
                    {
                        <a href="@Url.Action("FindToken", new { id = episode.Id, allow = false })">禁止下载</a>
                    }
                    <a href="@Url.Action("FindToken", new { id = episode.Id })">检测标记</a>
                    <a href="@Url.Action("Edit", new { id = episode.Id })">编辑</a>
                    <a href="@Url.Action("Delete", new { id = episode.Id })" class="delete">删除</a>
                </td>
            </tr>
        }
        </tbody>
        </table>
    </div>
    }
</div>
